package com.gather.spring.retry.cglib.proxy;

import com.gather.spring.retry.cglib.request.QueryUserCondition;
import com.gather.spring.service.cglib.OutService;
import com.gather.spring.service.cglib.UserService;
import com.gather.spring.service.cglib.UserServiceImpl;
import com.gather.po.User;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author kxd
 * @date 2018/12/5 14:08
 * description:
 */
@Slf4j
public class AnnotationCaseRetryProxy {
    @Autowired
    OutService outService;

    @Test
    public void failUserServiceTest() {
        UserService realService = new UserServiceImpl(outService);
        //DynamicProxy获取代理 jdk使用接口方式生成代理
        UserService proxyService = (UserService) DynamicProxy.getProxy(realService);
        User user = proxyService.queryUser(new QueryUserCondition());
        log.info("failUserServiceTest", user);
    }


    @Test
    public void cglibProxyCase() {
        CglibProxy proxy = new CglibProxy();
        UserService realService = (UserService) proxy.getProxy(UserServiceImpl.class);
        realService.queryUser(new QueryUserCondition());
    }
}
